class Solution(object):
    def numberOfMatches(self, n):
        """
        :type n: int
        :rtype: int
        """
        n_peidui = 0
        while n > 1:
            if n % 2 == 0:
                n_peidui += n // 2
                n = n // 2
            else:
                n_peidui += (n -1) // 2
                n = (n - 1) // 2 + 1
        return n_peidui
    
if __name__ == '__main__':
    n = 14
    print(Solution().numberOfMatches(n))